<%@page contentType="text/html; charset=UTF-8" isELIgnored="false"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/style.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/Js/jquery.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/Js/bootstrap.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/Js/ckform.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/Js/common.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/jq/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/jq/jquery-form.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<form class="form-inline definewidth m20" action="${pageContext.request.contextPath}/node/some5.do" id="rolename">
机构名称：
    <input type="text" name="name" id="name" class="abc input-default" placeholder="请输入机构名" value="">&nbsp;&nbsp;  
    <button type="button" class="btn btn-primary" onclick="select()">查询</button>&nbsp;&nbsp; <button type="button" class="btn btn-success" id="addnew">新增机构</button>
</form>
<table class="table table-bordered table-hover definewidth m10" >
    <thead>
    <tr>
        <th>机构编号</th>
        <th>机构名称</th>
        <th>状态</th>
        <th>管理操作</th>
    </tr>
    </thead>
	     <c:forEach items="${page.datas }" var="node">
	     <tr>
            <td>${node.code }</td>
            <td>${node.name}</td>
            <td>${node.state == 1 ? "启用" : "禁用"}</td>
            <td>
                  <a href="#" onclick="edit(${node.id},${page.pageno })">修改</a>
                  <a href="#" onclick="del(${node.id },${page.pageno })">删除</a>
                  
                  
            </td>
        </tr>                    
	     </c:forEach>
	     </table>
<div class="inline pull-right page">
<c:choose>
				<c:when test="${page.totalPages } == 1">
				 首页 上一页  下一页  末页 第${page.pageno }/${page.totalPages }页 ${page.totalRows }条记录
				</c:when>
				 <c:when test="${page.pageno == 1 }">
				  首页  上一页 <a href="${pageContext.request.contextPath }/node/some2.do?pageno=${page.pageno + 1}">下一页 </a><a href="${pageContext.request.contextPath }/node/some2.do?pageno=${page.totalPages}">末页 </a>第${page.pageno }/${page.totalPages }页 ${page.totalRows }条记录
				 </c:when>
				 <c:when test="${page.pageno == page.totalPages }">
				<a href="${pageContext.request.contextPath }/node/some2.do?pageno=1">首页</a> <a href="${pageContext.request.contextPath }/node/some2.do?pageno=${page.pageno - 1}">上一页 </a>  下一页  末页 第${page.pageno }/${page.totalPages }页 ${page.totalRows }条记录
				 </c:when>
				 <c:otherwise>
				 <a href="${pageContext.request.contextPath }/node/some2.do?pageno=1"> 首页</a> <a href="${pageContext.request.contextPath }/node/some2.do?pageno=${page.pageno - 1}">上一页 </a> <a href="${pageContext.request.contextPath }/node/some2.do?pageno=${page.pageno + 1}"> 下一页</a> <a href="${pageContext.request.contextPath }/node/some2.do?pageno=${page.totalPages}">末页 </a>第${page.pageno }/${page.totalPages } 页 ${page.totalRows }条记录
				 </c:otherwise>
				</c:choose>
</div>
</body>
</html>
<script>
    $(function () {
        
		$('#addnew').click(function(){

				window.location.href="${pageContext.request.contextPath}/Node/node_add.jsp";
		 });


    });
    
    
    
    function edit(id,pageno){
        location.href="${pageContext.request.contextPath}/node/some3.do?id="+id+"&pageno="+pageno;	
    }
    
    
    
	function del(id,pageno)
	{
		if(confirm("确定要删除吗？"))
		{
			var url = "${pageContext.request.contextPath}/node/some6.do?id="+id+"&pagno="+pageno;
			
			window.location.href=url;		
		
		}
	}

	
	
		function select(){
        var name=document.getElementById("name").value;
		location.href="${pageContext.request.contextPath }/node/some2.do?name="+name+"&pageno=1";	
        //$.post("${pageContext.request.contextPath }/node/some2.do",{ name: name},{pageno:"1"} );
		}
		
		
		
	
</script>